﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>欢喜过新年,拼手气分2亿</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="css/payment.css"/>
    <script src="http://cdn.iyaoread.com/js/jquery-1.8.1.min.js"></script>
    <script src="js/jQuery.textSlider.js"></script>
    <style>
        .codeCeng{width: 100%; height: 100vh;background: rgba(0,0,0,.8);position: fixed;top: 0;left: 0;text-align: center;display: none}
        .codeCeng img{width: 40%;margin-top: 40%}
        .codeCeng p{margin-top: 10px;font-size: 18px;color: #fff}
    </style>
</head>
<body style="background: #ffe600">
<header style="position: relative">
    <div class="p_d1" style="">
       <div class="p_d2">
            <div id="scrollDiv" style="height: 25px;overflow: hidden">
                <div class="scrollText">
                    <ul style="margin-top: 0;" id="text">
                    </ul>
                </div>
            </div>
        </div>
    </div>
    <img src="http://yuedupic.iyaoread.com/hongbao/beijing_01.png" alt=""/>
    <div class="p_d3" style="" id="dx">
    </div>
</header>
<section class="p_section">
    <div class="p_d5">
        <img src="http://yuedupic.iyaoread.com/hongbao/text-box.png" alt="" style="width: 100%;"/>
        <div class="p_d6">
            <p class="p_p1" style="">活动说明</p>
            <div class="p_d7">
                 <p>支付1元,将获得0.1元到10元的随机红包</p>
                 <p>支付5元,将获得0.5元到100元的随机红包</p>
                 <p>支付10元,将获得1元到200元的随机红包</p>
            </div>
            <div class="p_d8">
                <img src="http://yuedupic.iyaoread.com/hongbao/fudai.png" alt=""/>
            </div>
        </div>
    </div>
</section>
<footer>
    <a><img src="http://yuedupic.iyaoread.com/hongbao/qiangOn.png" alt=""/></a>
    <a href="grabMoney.html"><img src="http://yuedupic.iyaoread.com/hongbao/payUn.png" alt=""/></a>
    <a href="Commission.html"><img src="http://yuedupic.iyaoread.com/hongbao/yongJUn.png" alt=""/></a>
    <a href="agent.html"><img src="http://yuedupic.iyaoread.com/hongbao/dailiUn.png" alt=""/></a>
    <a href="service.html"><img src="http://yuedupic.iyaoread.com/hongbao/kefuUn.png" alt=""/></a>
</footer>
<div class="tanchuceng">
    <div class="hongbao">
        <div class="close" style=""><img src="http://yuedupic.iyaoread.com/hongbao/close.png" alt=""/></div>
    </div>
</div>
<div class="codeCeng">
    <img src="http://yuedupic.iyaoread.com/hongbao/qrcode.jpg" alt=""/>
    <p>请先关注公众号</p>
</div>
<script src="js/jweixin-1.0.0.js"></script>
<script src="http://cdn.iyaoread.com/js/zepto.min.js"></script>
<script src="js/properties.js"></script>
<script>
$(document).ready(function(){
	var endTime2  = new Date().getTime();
	$.ajax({
        type: 'GET',
        url: "/activity/"+endTime2+"/list",
        dataType:"json",
        success:function(data){
          if(data.code==0){
        	  var arrya=data.data;
        	  var s = "";
        	  for(var i = 0;i<arrya.length;i++){
        		   var objc = arrya[i];
        		   s += '<div class="p_d4" onclick="onBridgeReady('+objc.id+')" style="position: relative">'+
        	            '<img src="http://yuedupic.iyaoread.com/hongbao/ry.png" alt=""/>'+
                       '<h1 >'+toDecimal(objc.payAmount/100.0)+'<span style="font-size:14px;color:#fff">元</span></h1></div>' 
              }
        	  $("#dx").html(s)
          }else if(data.code==99){
        	  window.location = baseUrl+"activity/homePage/payment";
          }
        },
        error:function(data){
            alert("请求失败！");
        }
    });
    $(".close").on("click",function(){
        $(".tanchuceng").hide(50);
    });
    $(".p_d4").on("click", function() {
        $(".tanchuceng").show(50);
    });
    $(".hongbao").click(function(){
    	window.location = "grabMoney.html";
    });
    $("#scrollDiv").textSlider({line:1,speed:500,timer:1500});
    $.ajax({
        type: 'GET',
        url: baseUrl+"activity/lkc",
        dataType:"json",
        success:function(data){
                var list=data.list;
                var s = "";
                for(var i = 0;i<list.length;i++){
                    var objc = list[i];
                    s += '<li>  玩家 <i>'+objc.name+'</i>   获得红包：'+objc.amount+'元；</li>'
                }
                $("#text").html(s);
        }
    });
});
var falg = true;
function onBridgeReady(id){
	if (falg) {
		falg = false;
		$.ajax({
	        url : "/activity/isConcern",
	        type: "GET",
	        dataType:"json",
	        success:function(data){
	            if(data.code == 0){
	                $(".codeCeng").show(50);
	            }else if(data.code == 1){
	            	pay(id);
	            }
	            else if(data.code == 2){
	          	  window.location = baseUrl+"activity/homePage/index";
	            }
	        }
	    });
	}
}

function pay(id){
	wx.config({
        debug: false,
        jsApiList: [
            'chooseWXPay'
        ]
    });
	var endTime2  = new Date().getTime();
    $.ajax({
        url : "/activity/"+endTime2+"/luckdraw?id="+id,
        type: "GET",
        dataType:"json",
        success:function(data){
        	if(data.code==0){
        		if(data.data.package == 'prepay_id=BALANCE'){
        			$(".tanchuceng").show(50);
        		}else{
                    WeixinJSBridge.invoke(
                            'getBrandWCPayRequest', {
                                "appId" : data.data.appId,
                                "timeStamp" : data.data.timeStamp+"",
                                "nonceStr" : data.data.nonceStr,
                                "package" : data.data.package,
                                "signType" : data.data.signType,         //微信签名方式：
                                "signature" : data.data.paySign,
                                "paySign" : data.data.paySign,
                                "sign":data.data.paySign
                            },
                            function(res){
                                if(res.err_msg == "get_brand_wcpay_request:ok" ) {
                                    $(".tanchuceng").show(50);
                                }
                        		falg = true;
                            }
                    );
        		}
        		
        	}else{
        		alert(data.data);
        	}
        },
        error:function(data){
            alert("服务器出错，请刷新页面！");
        }
    });
}
function toDecimal(x) { 
    var f = parseFloat(x); 
    if (isNaN(f)) { 
      return; 
    } 
    f = Math.round(x*100)/100; 
    return f; 
}
</script>
</body>
</html>